package com.szrt.java.day20161228.demo02;

import java.util.Arrays;

/**
 * 0:1 1:2 2:3 3:4 
 * 0:1 1:2 2:3 
 * 0:1 1:2 
 * 0:1 
 * @author zsrt
 *
 */

public class PopSort {

	public static void main(String[] args) {
		
		int[] arrays = new int[]{90,30,70,20,50};
		System.out.println("将要排序的数组为：");
		System.out.print(Arrays.toString(arrays));
		System.out.println();
		
		for(int outer =1;outer<=4;outer++){
			
			for(int inner =1;inner<=5-outer;inner++){
				
				int first = inner -1;
				int second = inner;
				//System.out.print(first+":"+second+" ");
				
				if(arrays[first] > arrays[second]){
					int temp;
					temp = arrays[first];
					arrays[first] = arrays[second];
					arrays[second] = temp;
				}
				
			}
			System.out.println("第"+outer+"次排序结果为："+Arrays.toString(arrays));
		}
		System.out.println("排序后的结果为："+Arrays.toString(arrays));
		
	}
	
}
